mod dgraph;
mod mysql;
mod sqlite;

use model_graph_types::{
    database::{DataSource, DatabaseType},
    extractor::{ExtractFromDatabaseOption, MetadataExtractor, MetadataPackage},
};

pub struct DefaultMetadataExtractor {}

#[async_trait::async_trait]
impl MetadataExtractor for DefaultMetadataExtractor {
    /// 根据数据库获取到元数据
    async fn extract_from_database(
        &self,
        data_source: &DataSource,
        options: ExtractFromDatabaseOption,
    ) -> anyhow::Result<MetadataPackage> {
        match data_source.database_type {
            DatabaseType::SQLite => sqlite::extract_from_database(data_source, options).await,
            DatabaseType::MySQL => mysql::extract_from_database(data_source, options).await,
            _ => Err(anyhow::anyhow!("不支持的数据库类型!")),
        }
    }
}
